// pages/collect/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    collect: [],
    tabs: [
      {
        id: 0,
        name: "商品收藏",
        isActive: true
      },
      {
        id: 1,
        name: "品牌收藏",
        isActive: false
      },
      {
        id: 2,
        name: "店铺收藏",
        isActive: false
      },
      {
        id: 3,
        name: "浏览足迹",
        isActive: false
      }
    ]
  },
  onShow: function () {
    let collect = wx.getStorageSync('collect') || [];
    this.setData({
      collect
    })
      
  },
  tabsItemChange: function (e) {
    let index = e.detail.index
    let tabs = this.data.tabs
    tabs.forEach(item => {
      if(item.id === index) {
        item.isActive = true
      } else {
        item.isActive = false
      }
    })
    this.setData({
      tabs
    })
  },
})